package lab02.test23;

/**
 * Created by admin on 2017/10/31.
 */
     import java.text.SimpleDateFormat;
     import java.util.*;
     import java.util.*;
     public class Birthday {
      public static void main(String[] args) {
        SimpleDateFormat dateFormat=new SimpleDateFormat("yyyy-MM-dd");
        Date dateNow=new Date();
        Date date=null;
        Scanner scanner=new Scanner(System.in);
        System.out.println("请输入你的生日，格式形如：2007-9-21:");
        String s=scanner.nextLine();
        try {
            date=dateFormat.parse(s);}
        catch (Exception e){
            System.out.println("输入错误");
        }
        Calendar calendar=Calendar.getInstance();
        calendar.setTime(date);
        Date dateBirthay=calendar.getTime();
        System.out.println("输出对应的是星期几：");
        System.out.println(calendar.get(Calendar.DAY_OF_WEEK));
        long countDay=(dateBirthay.getTime()-dateNow.getTime())/(24*60*60*1000);
        while (countDay<=0){
            countDay+=365;
        }
        System.out.println("距离你的生日还有"+countDay+"天。");
    }
}

